package cn.tedu.weibo.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class WebMVCConfig implements WebMvcConfigurer {
    @Override
    public void addCorsMappings(CorsRegistry registry){
        registry.addMapping("/**")
                .allowedHeaders("*") //允许任意访问
                .allowedMethods("*") //允许任意请求方式(get/post/put/delete)访问
                .allowedOriginPatterns("*") //允许任意的域访问
                .allowCredentials(true) //允许携带cookie/Session相关访问
                .maxAge(3600);  //一小时内同一请求内不再检测 直接放行
    }

}
